home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
cpp_libs
/
awe2-0_1.lha
/
awe2-0.1
/
Src
/
RCS
/
SpinBarrier.cc,v
< prev
next >
Wrap
Text File
|
1989-02-22
|
3KB
|
220 lines
head 3.2;
branch ;
access ;
symbols ;
locks grunwald:3.2; strict;
comment @@;
3.2
date 89.02.20.15.37.31; author grunwald; state Exp;
branches ;
next 3.1;
3.1
date 88.12.20.13.49.17; author grunwald; state Exp;
branches ;
next 1.4;
1.4
date 88.10.30.13.04.38; author grunwald; state Exp;
branches ;
next 1.3;
1.3
date 88.09.28.22.13.21; author grunwald; state Exp;
branches ;
next 1.2;
1.2
date 88.09.21.20.51.29; author grunwald; state Exp;
branches ;
next 1.1;
1.1
date 88.09.18.16.42.23; author grunwald; state Exp;
branches ;
next ;
desc
@@
3.2
log
@Start using Gnu library heaps for schedulers
@
text
@// This may look like C code, but it is really -*- C++ -*-
//
// Copyright (C) 1988 University of Illinois, Urbana, Illinois
//
// written by Dirk Grunwald (grunwald@@cs.uiuc.edu)
//
#include "SpinBarrier.h"
#include "Pragma.h"
PRAGMA_LINKAGE_C
extern int getpid();
PRAGMA_LINKAGE
extern void makeVolatile( void * );
//
// Make everyone exit
//
void
SpinBarrier::lowerBarrier()
{
reserve();
generation++;
pCount = 0;
release();
}
int
SpinBarrier::rendezvous()
{
reserve();
pCount++;
//
// Waiting people just read generation, and the final process
// just writes it, so we don't really even need to use the locks here.
//
if ( pCount == pHeight ) {
pCount = 0;
generation++;
release();
} else {
int gen = generation;
release();
int timesAround = 0;
int totalGetPids = 0;
while ( gen == generation ) {
if ( timesAround > pLoops ) {
(void) getpid();
timesAround = 0;
totalGetPids++;
if ( pMaxLoops > 0 && totalGetPids > pMaxLoops ) {
return(0);
}
}
timesAround++;
makeVolatile(&gen);
}
}
return(1);
}
void
SpinBarrier::height(int newHeight)
{
reserve();
if (pCount >= newHeight) {
pCount = 0;
generation++;
}
else {
pHeight = newHeight;
}
release();
}
@
3.1
log
@Steay version
@
text
@@
1.4
log
@*** empty log message ***
@
text
@d8 1
d10 1
d12 1
d14 5
d20 1
a20 1
SpinBarrier::rendezvous()
a21 2
int timesAround = 0;
d23 2
a24 2
int gen = generation;
count++;
d26 1
d28 6
d38 4
a41 3
if ( count == pHeight ) {
count = 0;
generation = gen + 1;
d43 4
d51 4
d57 1
d60 15
@
1.3
log
@*** empty log message ***
@
text
@d1 7
a7 1
#include "HardBarrier.h"
d12 1
a12 1
HardBarrier::rendezvous()
@
1.2
log
@*** empty log message ***
@
text
@a4 2
const int MaxTimesAround = 1000;
d10 1
a10 1
lock.reserve();
d13 1
a13 1
lock.release();
d24 1
a24 1
if (timesAround > MaxTimesAround) {
@
1.1
log
@Initial revision
@
text
@d5 2
d10 2
d15 6
d23 9
a31 5
generation++;
} else while ( gen == generation ) {
lock.release();
(void) getpid();
lock.reserve();
a32 1
lock.release();
@